package io.gitee.kenewstar.dbmq.thread;

import cn.hutool.core.thread.ThreadUtil;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;


/**
 * @author kenewstar
 */
public class DbMqConsumerThreadPool {

    private ScheduledExecutorService scheduledExecutor;
    private WorkThreadPool workThreadPool;

    public DbMqConsumerThreadPool() {}

    public DbMqConsumerThreadPool(WorkThreadPool workThreadPool) {
        this.scheduledExecutor = ThreadUtil.createScheduledExecutor(1);
        this.workThreadPool = workThreadPool;
    }


    public void executeScheduledTask(Runnable task, long period) {
        this.scheduledExecutor.scheduleAtFixedRate(task, period, period, TimeUnit.MILLISECONDS);
    }

    public WorkThreadPool getWorkThreadPool() {
        return this.workThreadPool;
    }

}
